<include target="category.html" />
<div class="x_clearfix" style="margin-bottom:10px">
	<div cond="$act == 'dispAutoinstallAdminIndex'" class="x_pull-left sort">
		<!--@if($order_target == 'newest')-->
			<!--@if($order_type == 'desc')-->{@$_newest_order_type = 'asc'}<!--@else-->{@$_newest_order_type = 'desc'}<!--@end-->
		<!--@else-->
			{@$_newest_order_type = 'desc'}
		<!--@end-->
		<!--@if($order_target == 'download')-->
			<!--@if($order_type == 'desc')-->{@$_download_order_type = 'asc'}<!--@else-->{@$_download_order_type = 'desc'}<!--@end-->
		<!--@else-->
			{@$_download_order_type = 'desc'}
		<!--@end-->
		<!--@if($order_target == 'popular')-->
			<!--@if($order_type == 'desc')-->{@$_popular_order_type = 'asc'}<!--@else-->{@$_popular_order_type = 'desc'}<!--@end-->
		<!--@else-->
			{@$_popular_order_type = 'desc'}
		<!--@end-->
		<a href="{getUrl('order_target','newest','order_type',$_newest_order_type,page,'')}" class="active"|cond="$order_target == 'newest'">{$lang->order_newest} <i cond="$order_target == 'newest'" class="x_icon-circle-arrow-down"|cond="$_newest_order_type == 'asc'" class="x_icon-circle-arrow-up"|cond="$_newest_order_type == 'desc'">{$_newest_order_type}</i></a>
		<i>|</i>
		<a href="{getUrl('order_target','download','order_type',$_download_order_type,page,'')}" class="active"|cond="$order_target == 'download'">{$lang->order_download} <i cond="$order_target == 'download'" class="x_icon-circle-arrow-down"|cond="$_download_order_type == 'asc'" class="x_icon-circle-arrow-up"|cond="$_download_order_type == 'desc'">{$_download_order_type}</i></a>
		<i>|</i>
		<a href="{getUrl('order_target','popular','order_type',$_popular_order_type,page,'')}" class="active"|cond="$order_target == 'popular'">{$lang->order_popular} <i cond="$order_target == 'popular'" class="x_icon-circle-arrow-down"|cond="$_popular_order_type == 'asc'" class="x_icon-circle-arrow-up"|cond="$_popular_order_type == 'desc'">{$_popular_order_type}</i></a></li>
	</div>
</div>

<div id="__list_simple">
	<div style="overflow:hidden;margin-bottom:10px">
		<strong style="position:relative;top:10px">
			<block cond="$current_category">{$current_category}</block>
			<block cond="!$current_category">All</block>
			({sprintf('%d', $page_navigation->total_count)})
		</strong>
		<div class="x_btn-group x_pull-right">
			<button class="x_btn x_active __btn_simple">{$lang->simple_view}</button>
			<button class="x_btn __btn_detail">{$lang->detail_view}</button>
		</div>
	</div>
	<div class="list">
		<block loop="$item_list => $key, $item">
			{@ $target_url = $original_site."?mid=download&package_srl=".$item->package_srl; }
			<div class="x_thumbnail">
				<div class="thumb" style="min-height:80px">
					<img src="{str_replace('./', $uri, $item->item_screenshot_url)}" alt="" style="width:80px;height:80px" />
				</div>
				<div class="text">
					<h3><span class="x_label x_label-info">{$item->category}</span> <a href="{$target_url}" title="{$item->title}" target="_blank">{$item->title}</a></h3>
					<p>
						<block cond="(int)$item->package_voter > 0">
							<span class="starRating"><span style="width:{sprintf("%d",$item->package_voted/$item->package_voter*20)}%">{sprintf("%0.1f",$item->package_voted/$item->package_voter*2)}{sprintf($lang->rate, $item->package_start)}</span></span>
							<span class="x_badge">{sprintf("%0.1f",$item->package_voted/$item->package_voter*2)}/{number_format($item->package_voter)}</span>
						</block>
						<block cond="(int)$item->package_voter <= 0">
							<span class="starRating"><span style="width:0%">0</span></span>
							<span class="x_badge">0/0</span>
						</block>
					</p>
					<p class="x_btn-group" style="text-align:right">
						<a cond="$item->current_version && $item->need_update != 'Y'" class="x_btn x_disabled" href="#">{$lang->installed}</a>
						<a cond="!$item->current_version" class="x_btn" href="{getUrl('act','dispAutoinstallAdminInstall','package_srl',$item->package_srl)}"><i class="x_icon-download-alt"></i> {$lang->install}</a>
						<a cond="!$show_ftp_note && $item->current_version && $item->avail_remove" class="x_btn" href="{getUrl('act','dispAutoinstallAdminUninstall','package_srl',$item->package_srl)}"><i class="x_icon-remove"></i> {$lang->cmd_delete}</a>
						<a cond="$item->current_version && $item->need_update == 'Y'" class="x_btn" href="{getUrl('act','dispAutoinstallAdminInstall','package_srl',$item->package_srl)}"><i class="x_icon-refresh"></i> {$lang->update}</a>
					</p>
				</div>
			</div>
		</block>
	</div>
</div>

<table id="__list_detail" class="x_table x_table-striped x_table-hover" style="display:none">
	<caption>
		<strong>
			<block cond="$current_category">{$current_category}</block>
			<block cond="!$current_category">All</block>
			({sprintf('%d', $page_navigation->total_count)})
		</strong>
		<div class="x_btn-group x_pull-right">
			<button class="x_btn x_active __btn_simple">{$lang->simple_view}</button>
			<button class="x_btn __btn_detail">{$lang->detail_view}</button>
		</div>
	</caption>
	<thead>
		<tr>
			<th scope="col" class="nowr">{$lang->thumbnail}</th>
			<th scope="col" class="nowr">{$lang->name}</th>
			<th scope="col" class="nowr">{$lang->distribute_version}</th>
			<th scope="col" class="nowr">{$lang->current_version}</th>
			<th scope="col" class="nowr">{$lang->run}</th>
		</tr>
	</thead>
	<tbody>
		<tr loop="$item_list => $key, $item">
			{@ $target_url = $original_site."?mid=download&package_srl=".$item->package_srl; }
			<td>
				<div class="x_thumbnail" style="width:80px;height:80px">
					<img src="{str_replace('./', $uri, $item->item_screenshot_url)}" alt="" width="100" height="100" />
				</div>
			</td>
			<td>
				<p><span class="x_label x_label-info">{$item->category}</span> <a href="{$target_url}" target="_blank">{$item->title}</a></p>
				<p style="margin:5px 0">{cut_str($item->package_description,200)}</p>
				<p style="margin:5px 0">
					<block cond="(int)$item->package_voter > 0">
						<span class="starRating"><span style="width:{sprintf("%d",$item->package_voted/$item->package_voter*20)}%">{sprintf("%0.1f",$item->package_voted/$item->package_voter*2)}{sprintf($lang->rate, $item->package_start)}</span></span>
						<span class="x_badge">{sprintf("%0.1f",$item->package_voted/$item->package_voter*2)}/{number_format($item->package_voter)}</span>
					</block>
					<block cond="(int)$item->package_voter <= 0">
						<span class="starRating"><span style="width:0%">0</span></span>
						<span class="x_badge">0/0</span>
					</block>
					{$lang->package_update}: <time title="{zdate($item->item_regdate, "Y-m-d H:i")}">{zdate($item->item_regdate, "Y-m-d")}</time> 
					<i>|</i>
					{$lang->package_downloaded_count}: {number_format($item->package_downloaded)}
					<i>|</i>
				</p>
				<p cond="$item->deps">{$lang->dependant_list}:</p>
				<ul cond="$item->deps" class="">
					<li loop="$item->deps => $package_srl">{$installed[$package_srl]->title}</li>
				</ul>
			</td>
			<td>{$item->item_version}</td>
			<td>{$item->current_version}</td>
			<td>
				<span class="x_btn-group">
					<a cond="$item->current_version && $item->need_update != 'Y'" class="x_btn x_disabled" href="#">{$lang->installed}</a>
					<a cond="!$item->current_version" class="x_btn" href="{getUrl('act','dispAutoinstallAdminInstall','package_srl',$item->package_srl)}"><i class="x_icon-download-alt"></i> {$lang->install}</a>
					<a cond="!$show_ftp_note && $item->current_version && $item->avail_remove" class="x_btn" href="{getUrl('act','dispAutoinstallAdminUninstall','package_srl',$item->package_srl)}"><i class="x_icon-remove"></i> {$lang->cmd_delete}</a>
					<a cond="$item->current_version && $item->need_update == 'Y'" class="x_btn" href="{getUrl('act','dispAutoinstallAdminInstall','package_srl',$item->package_srl)}"><i class="x_icon-refresh"></i> {$lang->update}</a>
				</span>
			</td>
		</tr>
	</tbody>
</table>
<div class="x_clearfix" style="margin-top:-10px">
	{@
		$urlInfo = parse_url(getRequestUriByServerEnviroment());
		parse_str($urlInfo['query'], $param);
	}
	<form cond="$page_navigation" action="./" class="x_pagination x_pull-left" no-error-return-url="true">
		<input loop="$param => $key, $val" cond="!in_array($key, array('mid', 'vid', 'act'))" type="hidden" name="{$key}" value="{$val}" />
		<ul>
			<li class="x_disabled"|cond="!$page || $page == 1"><a href="{getUrl('page', '')}">&laquo; {$lang->first_page}</a></li>
			<block cond="$page_navigation->first_page != 1 && $page_navigation->first_page + $page_navigation->page_count > $page_navigation->last_page - 1 && $page_navigation->page_count != $page_navigation->total_page">
			{@$isGoTo = true}
			<li>
				<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
				<span cond="$isGoTo" id="goTo" class="x_input-append">
					<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
					<button type="submit" class="x_add-on">Go</button>
				</span>
			</li>
			</block>
			<!--@while($page_no = $page_navigation->getNextPage())-->
			{@$last_page = $page_no}
			<li class="x_active"|cond="$page_no == $page"><a  href="{getUrl('page', $page_no)}">{$page_no}</a></li>
			<!--@end-->
			<block cond="$last_page != $page_navigation->last_page && $last_page + 1 != $page_navigation->last_page">
			{@$isGoTo = true}
			<li>
				<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
				<span cond="$isGoTo" id="goTo" class="x_input-append">
					<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
					<button type="submit" class="x_add-on">Go</button>
				</span>
			</li>
			</block>
		<li class="x_disabled"|cond="$page == $page_navigation->last_page"><a href="{getUrl('page', $page_navigation->last_page)}" title="{$page_navigation->last_page}">{$lang->last_page} &raquo;</a></li>
		</ul>
	</form>
	<form action="./" class="search x_input-append x_pull-right" no-error-return-url="true" cond="$act!=dispAutoinstallAdminInstalledPackages">
		<input loop="$param => $key, $val" cond="!in_array($key, array('mid', 'vid', 'act', 'page'))" type="hidden" name="{$key}" value="{$val}" />
		<input type="search" name="search_keyword" required title="Search" value="{htmlspecialchars($search_keyword)}">
		<button class="x_btn x_btn-inverse" type="submit">{$lang->cmd_search}</button>
		<a href="{getUrl('page', '', 'search_keyword', '')}" class="x_btn">{$lang->cmd_cancel}</a>
	</form>
</div>
<script>
jQuery(function($){
	var $btnSimple = $('.__btn_simple');
	var $btnDetail = $('.__btn_detail');
	var $listSimple = $('#__list_simple');
	var $listDetail = $('#__list_detail');

	$btnSimple.click(function(){
		$btnSimple.addClass('x_active');
		$btnDetail.removeClass('x_active');
		$listSimple.show();
		$listDetail.hide();
		setCookie('__autoinstall_view_type', 'simple');
	});

	$btnDetail.click(function(){
		$btnSimple.removeClass('x_active');
		$btnDetail.addClass('x_active');
		$listSimple.hide();
		$listDetail.show();
		setCookie('__autoinstall_view_type', 'detail');
	});

	var viewType = getCookie('__autoinstall_view_type');
	if(viewType == 'detail'){
		$btnDetail.trigger('click');
	}
	$('.list>.x_thumbnail:odd').addClass('even');
	$('.list>.x_thumbnail:even').addClass('odd');
});
</script>
